import { createApp } from "vue";
import App from "@/App.vue"; // 跟组件
import "@/static/styles/index.less";
import router from "@/router/interceptor"; // 路由
import { createPinia } from "pinia"; // 全局状态
import i18n from "@/locale"; // 国际化
import components from "./components"; // 全局组件
import Icons from "./ant-icons"; // 全局图标组件
import directives from "@/directive"; // 全局自定义指令
import * as globalComponents from "@/components/global";
const app = createApp(App);

// 全局自定义指令
directives.forEach((fn) => fn(app));

// ant-design全局组件
for (const component of components) {
  app.use(component);
}
// 自定义全局组件
for (const name in globalComponents) {
  app.component(name, (globalComponents as any)[name].default);
}

// 全局ant图标组件
app.use(Icons);

// 国际化
app.use(i18n);

// 路由
app.use(router);

// 全局状态
const pinia = createPinia();
app.use(pinia);

app.mount("#app");
